package com.boot4g.admin.module.sys.controller;

import com.boot4g.admin.module.sys.service.ShiroService;
import com.boot4g.entity.SysUserEntity;
import com.boot4g.entity.SysUserTokenEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;


/**
 * 权限查询接口.
 * 
 * @author chenjinjie
 * @email guangyaoliangzijie@163.com
 * @date 2017-08-27 15:23:47
 */
@RestController
@RequestMapping("/admin/shiro")
public class SysShiroController extends AbstractController {
	@Autowired
	private ShiroService shiroService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/user-permissions")
	public Set<String> getUserPermissions(@RequestParam("userId") long userId){
		Set<String> deptSet = shiroService.getUserPermissions(userId);

		return deptSet;
	}
	@RequestMapping("/query-by-token")
	public SysUserTokenEntity queryByToken(@RequestParam("token") String token) {
		SysUserTokenEntity sysUserTokenEntity = shiroService.queryByToken(token);
		return sysUserTokenEntity;
	}

	/**
	 * 根据用户ID，查询用户
	 * @param userId
	 */
	@RequestMapping("/query-user")
	public SysUserEntity queryUser(@RequestParam("userId") long userId) {
		SysUserEntity sysUserEntity = shiroService.queryUser(userId);
		return sysUserEntity;
	}
}
